import puppeteer from 'puppeteer';
import xlsx from 'node-xlsx';
import GoLogin from '../src/gologin.js';
import readline from 'readline';
import fs from 'fs';
import request from 'request';
import { authenticator } from 'otplib';

let token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2MzgyMjYxYmJhNjczZWQ2YjU0NTU5NzYiLCJ0eXBlIjoiZGV2Iiwiand0aWQiOiI2NDU0NzlhYzdhZWEzMmVmOWY3Mjk3ZGUifQ.f1Kj2S6iqgKGA5Oep_mfMWiPktEvOP5ZYWnUlF7f3Og';

let GL = new GoLogin({
  token: token,
  profile_id: '6681bafb7873033ba64a5fe5',
  extra_params: ['--start-maximized'],
  uploadCookiesToServer: true,

  tmpdir:'C:\\Users\\Administrator\\AppData\\Local\\Temp\\'

});
await GL.checkBrowser()
const wsUrl = await GL.start();
let data = wsUrl.wsUrl;
console.log(data);

const browser = await puppeteer.connect({
  browserWSEndpoint: data,
  ignoreHTTPSErrors: true,
  extra_params: ['--start-maximized'],
});

let pages = await browser.pages();
let length = (await browser.pages()).length;
const page = pages[pages.length - 1];
// await page.goto('https://app.fuel.network/bridge?from=fuel&to=et');
await page.goto('https://www.swayfarm.xyz/');
// promise[0].goto('h');
await GL.commitProfile();
await GL.uploadProfileCookiesToServer();
